<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Ft extends CI_Controller {

	     public function __construct()
       {
            parent::__construct();
		$this->load->helper("html");
		$this->load->helper("url");
		$this->load->helper('form');
		$this->load->helper('date');
		$this->load->model("ft_model");
		//$this->load->model("guest_comment_model");
		//$this->load->model("news_events_model");
		//$this->load->model("roomcottages_model");
		$this->load->helper(array('form', 'url'));
		$this->load->database();
		
	}
	
	//START ------------------em---------------------
	function index()
	{
		$data['title']="Administrator Page";
		$data["list_fts"] = $this->ft_model->get_all_ft();	
		$this->load->view('ft_list_view',$data);
	}

	function view_ft()
	{
		$data['title']="Administrator Page";
		$code = $this->uri->segment(3);
		$data["list_fts"] = $this->ft_model->getft_info($code);
		//$data["list_customers"] = $this->customers_model->getcustomers();
		$this->load->view('ft_list_view',$data);
		
	}
	
	function add_ft()
	{
		//$data["driver_em_data"] = $this->em_model->add_view_driver_em();
		$this->load->view('ft_add_view');
	}
	function p_add_ft()
	{
		
		$this->load->database();			

		
		$bc_company_name =$_POST['bc_company_name'];
		$from_st =$_POST['txtfrom_st'];			
		$to_st =$_POST['txtto_st'];
				//		$contract_amt =$_POST['txtcontract_amt'];
										 
		$_sql="insert into from_to(bc_company_name,from_st,to_st)";
		$_sql.="values('$bc_company_name','$from_st','$to_st')";
		$query = $this->db->query($_sql); 
	/*	$em_id=$this->db->insert_id();
	 
		$_sql="insert into em_contract(em_id,contract_amount)";
		$_sql.="values($em_id,$contract_amt)";
		$query = $this->db->query($_sql); */
			
		$data["list_fts"] = $this->ft_model->get_all_ft();	
		$this->load->view('ft_list_view',$data);
							
	}

	function edit_ft()
	{
 	    $code = $this->uri->segment(3);
		$data["info"] = $this->ft_model->getft_info($code);	
		$this->load->view('ft_edit_view',$data);
	}
	
	function p_edit_ft()
	{
		$this->load->database();
	    $broker_code= $_POST['hid_broker_code'];
		$bc_company_name =$_POST['bc_company_name'];
		$from_st =$_POST['txtfrom_st'];			
		$to_st =$_POST['txtto_st'];
			$query = $this->db->query("UPDATE from_to SET 
														  	bc_company_name='$bc_company_name',
														  	from_st='$from_st',
														  	to_st='$to_st' where broker_code=$broker_code");
														  
		$data["list_fts"] = $this->ft_model->get_all_ft();	
		$this->load->view('ft_list_view',$data);		
	}
	
	
	function delete_ft()
	{
		$this->load->database();		
		$code = $this->uri->segment(3);
		$query = $this->db->query("delete from ft where broker_code='$code'");
		
		$data["list_ems"] = $this->ft_model->get_all_ft();	
		$this->load->view('ft_list_view',$data);
	}
	//END ------------------em---------------------
	
	
	function logout()
	{
		
		//$this->load->library('session');
		//$this->session->sess_destroy();
		session_start();
		session_destroy();
		//echo $_SESSION['Administrator_log'];
		//unset($_SESSION['Administrator_log']);
		
			//$data["newsresult"] = $this->em_model->em_all_driver_em();
			$this->load->view('admin_view');
	 
	}
 
}
?>